home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17056 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.9 KB  |  71 lines

  1. Path: informatik.tu-muenchen.de!schuenem
  2. From: schuenem@informatik.tu-muenchen.de (Ulf Schuenemann)
  3. Newsgroups: comp.lang.smalltalk,comp.object,comp.lang.c++,comp.lang.java
  4. Subject: Re: The Good, the Bad, the Ugly, and the Wicked ...
  5. Date: 12 Apr 1996 15:31:31 GMT
  6. Organization: Technische Universitaet Muenchen, Germany
  7. Distribution: world
  8. Message-ID: <4klt0j$i0m@sunsystem5.informatik.tu-muenchen.de>
  9. References: <31570B8E.5A12@vmark.com> <4je5rq$7qg@mimas.brunel.ac.uk>  <4jes0t$gth@decaxp.HARVARD.EDU> <31630E30.5A02@oma.com>  <4kbq3q$1i8@gaia.ns.utk.edu> <JSA.96Apr9131057@organon.com>  <RMARTIN.96Apr10133335@rcm.oma.com> <JSA.96Apr11153135@organon.com>
  10. NNTP-Posting-Host: hpbroy7.informatik.tu-muenchen.de
  11. Originator: schuenem@hpbroy7.informatik.tu-muenchen.de
  12.  
  13.  
  14. [**] This is intended to be an information post.
  15.  
  16. To the discussion Smalltalk vs C++ let me focus on the point
  17. of two classes of errors that may occure:
  18.  
  19. a) access to illegal memory    (here: released memory)
  20. b) calling illegal methods
  21.  
  22. A language has three main choices what to do:
  23. #1 prohibit such errors
  24. #2 catch such errors and report them (some kind of exception mechanism)
  25. #3 don't bother - ie undefined behavior
  26. I count the catching of illegal memory access by the operating system
  27. (which, in unix, results in core dump) as #3.
  28.  
  29. Means to achieve this:
  30.         a) access to illegal memory    b) calling illegal methods
  31. --------------------------------------------------------------------------
  32. #1 prohibit:    GC-systems            static typecheck
  33. #2 catch:    bounds-checkers            "Message not understood"
  34. #3 don't:    -                -
  35.  
  36. In C++ access to memory that has been released by 'delete' is illegal.
  37. But what happens at runtime is implementation-defined.
  38. Most implementations do a-#3.
  39. Trying to achieving GC-semantics (a-#1) for an ordinary C++ program by
  40. making it's calls to 'delete' a no-op would allow access to an object
  41. who's destructor has been called - which is illegal.
  42.  
  43. C++ is b-#1: All implemenations do static typecheck (as the language is
  44. defined in a way that makes static typecheck manageable).
  45.  
  46. Smalltalk requires GC (a-#1) as it has no construct for releasing memory.
  47.  
  48. I've only heard of implementations that do b-#2.
  49. I don't know the Smalltalk language definition to tell whether b-#3 is
  50. allowed or wheter the famous "Message not understood" is required.
  51. I estimate it would be impossible to do static typecheck in Smalltalk
  52. without a global data-flow-analysis.
  53.  
  54. Result:
  55.  
  56. Smalltalk:    a-#1    b-#2
  57. C++:        a-#3    b-#1
  58. Eiffel:        a-#1    b-#1 [*]
  59. [*] I don't know how covariant overriding of parametertypes (which is not
  60.     typesave but allowed Eiffel) is handled by Eiffel implementations.
  61.  
  62. I obstain from any personal judgement.
  63.  
  64. Ulf Schuenemann
  65.  
  66. --------------------------------------------------------------------
  67.  ,_.   Ulf Schⁿnemann
  68. #,  \  FakultΣt fⁿr Informatik, Technische UniversitΣt Mⁿnchen, Germany.
  69.  |   > email: schuenem@informatik.tu-muenchen.de
  70.  v=-<  WWW:   http://hphalle2.informatik.tu-muenchen.de/~schuenem/
  71.